package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CustomerPageQueryDTO;
import com.sky.entity.Customer;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CustomerMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from customer where username = #{username}")
    Customer getByUsername(String username);

    /**
     * 插入员工数据
     * @param customer
     */
    @Insert("insert into customer(" +
            " name,username,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user) " +
            "values " +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})" )
    @AutoFill(value = OperationType.INSERT)
    void insert(Customer customer);

    /**
     * 分页查询
     * @param customerPageQueryDTO
     * @return
     */
    Page<Customer> pageQuery(CustomerPageQueryDTO customerPageQueryDTO);

    /**
     * 修改员工信息
     * @param customer
     */
    @AutoFill(value = OperationType.INSERT)
    void update(Customer customer);


    /**
     * 根据ID查询员工信息
     * @param id
     */
    @Select("select * from customer where id=#{id}")
    Customer getById(Long id);


}
